package com.gxa.retail_admin.controller;


import com.gxa.common.vo.ResultVo;
import com.gxa.modules.pojo.R_User;
import com.gxa.modules.pojo.Region;
import com.gxa.modules.pojo.Shop;
import com.gxa.modules.service.RegionService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@Controller
@RequestMapping("/operation/area")
@Api(value = "区域管理Test",tags = "区域管理接口API-刘辉")
public class RegionController {
    @Autowired(required = false)
    private RegionService RegionServiceImpl;
    /**
     *查询区域列表接口
     */
    @ApiOperation(value = "查询区域列表接口",notes = "区域列表信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @GetMapping("/region")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo queryRegionList(Integer currentPage,Integer pageSize){
//        Region region=new Region();
//        region.setRe_id(101);
//        region.setRe_name("成都合伙区");
//        region.setRe_range("成都市武侯区");
//        region.setRe_phone("17859641556");
        ResultVo resultVo=RegionServiceImpl.queryRegionList(currentPage,pageSize);
//        ResultVo resultVo=new ResultVo();
//        resultVo.setCode(200);
//        resultVo.setData(region);
//        resultVo.setMsg("查询成功");
        return resultVo;
    }

    /**
     *查询经营中的区域接口
     */
    @ApiOperation(value = "查询经营中的区域接口",notes = "经营中区域的列表信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @GetMapping("/manage")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo queryByStatus1(Integer currentPage,Integer pageSize){
//        Region region1=new Region();
//        region1.setRe_id(101);
//        region1.setRe_name("成都合伙区");
//        region1.setRe_range("成都市武侯区");
//        region1.setRe_phone("17859641556");
//        Region region2=new Region();
//        region2.setRe_id(102);
//        region2.setRe_name("重庆合伙区");
//        region2.setRe_range("重庆市");
//        region2.setRe_phone("15884526359");
//        List list=new ArrayList();
//        list.add(region1);
//        list.add(region2);
//        ResultVo resultVo=new ResultVo();
//        resultVo.setCode(200);
//        resultVo.setData(list);
//        resultVo.setMsg("查询成功");
        ResultVo resultVo=RegionServiceImpl.queryByStatus1(currentPage,pageSize);

        return resultVo;
    }

    /**
     *查询停业的区域接口
     */
    @ApiOperation(value = "查询停业的区域接口",notes = "停业区域的列表信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @GetMapping("/closed")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo queryByStatus2(Integer currentPage,Integer pageSize){
        ResultVo resultVo=RegionServiceImpl.queryStatus2(currentPage,pageSize);
        return resultVo;
    }

    /**
     * 区域管理根据条件搜索接口
     */
    @ApiOperation(value = "条件搜索接口",notes = "搜索区域列表信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "status",value = "区域状态",paramType = "query",dataType = "int"),
            @ApiImplicitParam(name = "re_name",value = "区域名称",paramType = "query",dataType = "String")

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @GetMapping("/searchByRegion")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo searchByRegion(Integer currentPage,Integer pageSize,Integer status,String re_name){
        ResultVo resultVo=RegionServiceImpl.search(currentPage,pageSize,status,re_name);
        return resultVo;
    }

    /**
     *区域列表批量开启接口
     */
    @ApiOperation(value = "批量开启接口",notes = "批量开启信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParam(name = "ids" ,value = "选中的id",paramType = "query",dataType = "int",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @GetMapping("/openBatchRegion")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo batchOpen(String[] ids){
        ResultVo resultVo=RegionServiceImpl.batchOpen(ids);
        return resultVo;
    }

    /**
     * 区域列表批量关闭接口
     */
    @ApiOperation(value = "批量关闭接口",notes = "批量关闭信息",httpMethod = "GET", response = ResultVo.class)
    @ApiImplicitParam(name = "ids" ,value = "选中的id",paramType = "query",dataType = "int",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @GetMapping("/closeBatchRegion")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo batchClose(String[] ids){
        ResultVo resultVo=RegionServiceImpl.batchClose(ids);
        return resultVo;
    }

    /**
     *创建区域接口
     */
    @ApiOperation(value = "创建区域接口",notes = "创建区域信息",httpMethod = "POST", response = ResultVo.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @PostMapping("/createRegion")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo createRegion(@RequestBody @ApiParam Map map){
        ResultVo resultVo=new ResultVo();
        return resultVo;
    }

    /**
     * 区域列表里面的编辑接口
     */
    @ApiOperation(value = "编辑接口",notes = "编辑信息",httpMethod = "POST", response = ResultVo.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @PostMapping("/editRegion")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo edit(@RequestBody Region region){
        ResultVo resultVo=new ResultVo();
        return resultVo;
    }

    /**
     * 修改密码接口
     */
    @ApiOperation(value = "修改密码接口",notes = "修改密码信息",httpMethod = "POST", response = ResultVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "oldPwd",value = "登陆密码",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "newPwd",value = "确认密码",paramType = "query",dataType = "String",required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @PostMapping("/updatePwd")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo update(String oldPwd,String newPwd){
        ResultVo resultVo=RegionServiceImpl.update(oldPwd,newPwd);
        return resultVo;
    }

    /**
     * 修改区域状态接口
     */
    @ApiOperation(value = "修改区域状态接口",notes = "修改",httpMethod = "POST", response = ResultVo.class)
   @ApiImplicitParams({
           @ApiImplicitParam(name = "re_id" ,value = "选中的id",paramType = "query",dataType = "int",required = true),
           @ApiImplicitParam(name = "re_status" ,value = "区域状态",paramType = "query",dataType = "int",required = true)

   })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code = 400,message = "参数接口错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @PostMapping("/updateByStatus")
    @RequiresPermissions("区域列表")
    @ResponseBody
    public ResultVo updateRegionStatus(Integer re_id,Integer re_status){
        ResultVo resultVo=RegionServiceImpl.updateRegionStatus(re_id,re_status);
        return resultVo;
    }


}
